home *** CD-ROM | disk | FTP | other *** search
- /*rx
- *
- * DelFilesLhA.rexx - Delete selected files from an LhA archive previously
- * listed in a DOpus window by ListLha.rexx
- *
- * $VER: DelFilesLhA 40.7 (03/01/94) by Geoff Seeley
- *
- * Usage: ARexx command DelFilesLhA.rexx (from DOpus)
- *
- */
-
- /* configuration variables (change these to suit your setup) */
-
- LhaCommand = 'XFH_Work:C/Archivers/File/LhA '
- OutputWindow = '>CON:30/145/640/100/LhA_Output/CLOSE/SCREENDOPUS.1 '
- DeleteList = 'T:lha_file_list'
- ListLhARexx = 'RX DOpus:ARexx/ListLhA.rexx'
-
- /*--------------------------------------------------------------------------*/
-
- /* misc. variables */
-
- DOpusPort = 'DOPUS.1'
-
- LhaDeleteCmd = '-x -m d '
-
- /* make sure we've got somebody to talk to */
-
- if showlist('Ports', DOpusPort) = 0 then do
- say 'Directory Opus ARexx port not found. Aborting.'
- call CleanUp
- end
-
- address 'DOPUS.1'
- options results
-
- TopText "Delete Files From an LhA Archive Buffer"
-
- Busy on
-
- /* get the path/name of the LhA archive file */
-
- 'Status 14 -1'
- LhaArchive = result
-
- /* make sure it's an LhA archive listing buffer */
-
- if (IsLhAFile(LhaArchive) = 0) then do
-
- /* try other window */
-
- OtherWindow
- 'Status 14 -1'
- LhaArchive = Result
-
- if (IsLhAFile(LhaArchive) = 0) then do
-
- Notify "Sorry, no LhA archive buffer found.\You must use the ListLha button first."
- call CleanUp
-
- end
-
- end
-
- /* get path to archive */
-
- call FindLhaPath
- LhaArchive = LhaPath || LhaArchive
-
- /* check for existance of archive */
-
- if ~exists(LhaArchive) then do
-
- Notify "Can't seem to find '" || LhaArchive || "'\Aborting."
- call CleanUp
-
- end
-
- /* check if LhA archive is empty */
-
- call GetFileCount
-
- if NumFiles = 0 then do
-
- call AskDelArchive
- TopText "LhA archive deleted."
- call CleanUP
-
- end
-
- /* get list of selected entries */
-
- GetSelectedAll
- SelectedEntries = result
-
- if SelectedEntries = 'RESULT' then do
-
- Notify "Please Select File(s) to Delete First..."
- call CleanUp
-
- end
-
- NumberOfEntries = words(SelectedEntries)
-
- /* make sure user wants it */
-
- Status 26
- OldOkay = result
-
- Status 27
- OldCancel = result
-
- Status 26 set 'Delete'
- Status 27 set 'Cancel'
-
- Request "Are You *SURE* You Want to DELETE the Selected File(s)?"
-
- DoDelete = Result
-
- /* reset previous values */
-
- Status 26 set OldOkay
- Status 27 set OldCancel
-
- Busy on
-
- if DoDelete = "1" then do
-
- /* delete the files */
-
- call DeleteFileList
-
- /* call ListLhA to re-list the LhA archive in the window */
-
- address command ListLhARexx
-
- Busy on
-
- /* get number of files left in archive */
-
- call GetFileCount
-
- if NumFiles = 0 then
-
- call AskDelArchive
-
- end
- else do
-
- TopText "Deleting File(s) Aborted..."
-
- call CleanUp
-
- end
-
- TopText "Finished Deleting Selected File(s) From LhA Archive."
-
- call CleanUp
-
- exit
-
- /*---------------------------------------------------------------------------*/
-
- DeleteFileList: /* build a list of selected files, delete list */
-
- /* toast possible old list */
-
- if exists(DeleteList) then
-
- delete(DeleteList)
-
- if ~open(FileList, DeleteList, 'W') then do
-
- Notify "Can't open file " || DeleteList
- call CleanUp
-
- end
-
- TopText "Creating File(s) List... Please Wait."
-
- do EntryNumber = 1 to NumberOfEntries
-
- /* get entry */
-
- Index = word(SelectedEntries, EntryNumber)
-
- GetEntry Index + 1
- Entry = result
-
- /* grab file name/path, protect in quotes */
-
- File = substr(Entry, 10)
- File = '"' || File || '"'
-
- /* make sure user see's the entry */
-
- ScrollToShow Index
-
- /* put it in the file list */
-
- call ReplaceMetaChars
- writeln(FileList, File)
-
- /* deselect this entry */
-
- selection = Index ||' '|| 0 ||' '|| 1
- SelectEntry selection
-
- end
-
- close(FileList)
-
- /* form CLI command and delete the file(s) */
-
- TopText "Deleting File(s) From LhA Archive... Please Wait."
-
- CliCommand = LhaCommand || OutputWindow || LhaDeleteCmd || LhaArchive
- CliCommand = CliCommand || ' @' || DeleteList
-
- address command CliCommand
-
- return
-
- /*---------------------------------------------------------------------------*/
-
- ReplaceMetaChars: /* replace special wildcards with ? */
-
- File = translate(File, '???', '()`', '?')
-
- return
-
- /*---------------------------------------------------------------------------*/
-
- IsLhAFile: procedure /* look at extension, return 1 if right, else 0 */
-
- parse arg AFileName
-
- lps = lastpos(".", AFileName)
- if lps = 0 then
- return 0
-
- FileExt = upper(right(AFileName,length(AFileName)-lps))
-
- if FileExt ~= "LHA" & FileExt ~= "LZH" then
- return 0
- else
- return 1
-
- return 0
-
- /*---------------------------------------------------------------------------*/
-
- FindLhAPath: /* grab invisible file path to archive */
-
- /* find number of entries, path is the last one */
-
- 'Status 6 -1'
-
- GetEntry Result
- LhaPath = Result
-
- return
-
- /*---------------------------------------------------------------------------*/
-
- GetFileCount: /* get the number of files in the LhA archive */
-
- /* number of files is the second to last line */
-
- 'Status 6 -1'
-
- Idx = Result - 1
-
- GetEntry Idx
-
- NumFiles = word(Result, 2)
-
- return
-
- /*---------------------------------------------------------------------------*/
-
- AskDelArchive: /* ask user if they wish to delete the archive */
-
- Status 26
- OldOkay = result
-
- Status 27
- OldCancel = result
-
- Status 26 set 'Delete'
- Status 27 set 'Cancel'
-
- Request "This LhA archive is now empty. Do you want to DELETE it?"
-
- DeleteArchive = Result
-
- /* reset previous values */
-
- Status 26 set OldOkay
- Status 27 set OldCancel
-
- Busy on
-
- if DeleteArchive = 1 then do
-
- if exists(LhaArchive) then
- delete(LhaArchive)
-
- /* buffer is toast, so clear it and scan in directory */
-
- 'ClearWin -1'
- ScanDir LhaPath
-
- end
-
- return
-
- /*---------------------------------------------------------------------------*/
-
- CleanUp: /* clean up files and exit */
-
- if exists(DeleteList) then
- delete(DeleteList)
-
- Busy off
-
- exit
-
- return
-
-